package playerclient;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import common.PlayerService;

public class PlayerClientTest {

	public static void main(String[] args) {
		try {
			String clientIPAddressEU = common.Tools.getproperty(
					"client.properties", "clientIPAddressEU");
			String clientIPAddressNA = common.Tools.getproperty(
					"client.properties", "clientIPAddressNA");
			String clientIPAddressAS = common.Tools.getproperty(
					"client.properties", "clientIPAddressAS");

			String hostEU = common.Tools.getproperty("client.properties",
					"serverName_EU");
			String hostNA = common.Tools.getproperty("client.properties",
					"serverName_NA");
			String hostAS = common.Tools.getproperty("client.properties",
					"serverName_AS");
			

			int RMIPortEU = Integer.parseInt(common.Tools.getproperty(
					"client.properties", "RMIPortEU"));
			int RMIPortNA = Integer.parseInt(common.Tools.getproperty(
					"client.properties", "RMIPortNA"));
			int RMIPortAS = Integer.parseInt(common.Tools.getproperty(
					"client.properties", "RMIPortAS"));
			
			Registry registryEU = LocateRegistry.getRegistry(hostEU, RMIPortEU);
			Registry registryNA = LocateRegistry.getRegistry(hostNA, RMIPortNA);
			Registry registryAS = LocateRegistry.getRegistry(hostAS, RMIPortAS);
			

			PlayerService playerServiceEU = (PlayerService) registryEU
					.lookup(common.Tools.getproperty("client.properties",
							"playerEU"));
			PlayerService playerServiceNA = (PlayerService) registryNA
					.lookup(common.Tools.getproperty("client.properties",
							"playerNA"));
			PlayerService playerServiceAS = (PlayerService) registryAS
					.lookup(common.Tools.getproperty("client.properties",
							"playerAS"));

			PlayerClient playerClientEU = new PlayerClient(playerServiceEU);
			PlayerClient playerClientNA = new PlayerClient(playerServiceNA);
			PlayerClient playerClientAS = new PlayerClient(playerServiceAS);
			
			/*new Thread(new PlayerClientCreateThread(playerClientEU, "Bill", "Clinton", 68, "Clinton",
					"bcbc1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "George", "Bush", 68, "Bush", "gbgb1234",
					clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Jinping", "Xi", 61, "Xi", "jxjx1234",
					clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Shinzo", "Abe", 60, "Abe", "sasa1234",
					clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Francois", "Hollande", 60, "Hollande",
					"fhfh1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientCreateThread(playerClientEU, "Angela", "Merkel", 60, "Merkel",
					"amam1234", clientIPAddressEU)).start();
			
			
			new Thread(new PlayerClientCreateThread(playerClientNA, "Bill", "Clinton", 68, "Clinton",
					"bcbc1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "George", "Bush", 68, "Bush", "gbgb1234",
					clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Jinping", "Xi", 61, "Xi", "jxjx1234",
					clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Shinzo", "Abe", 60, "Abe", "sasa1234",
					clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Francois", "Hollande", 60, "Hollande",
					"fhfh1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientCreateThread(playerClientNA, "Angela", "Merkel", 60, "Merkel",
					"amam1234", clientIPAddressNA)).start();
			
			new Thread(new PlayerClientCreateThread(playerClientAS, "Bill", "Clinton", 68, "Clinton",
					"bcbc1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "George", "Bush", 68, "Bush", "gbgb1234",
					clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Jinping", "Xi", 61, "Xi", "jxjx1234",
					clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Shinzo", "Abe", 60, "Abe", "sasa1234",
					clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Francois", "Hollande", 60, "Hollande",
					"fhfh1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientCreateThread(playerClientAS, "Angela", "Merkel", 60, "Merkel",
					"amam1234", clientIPAddressAS)).start();*/
			
			/*new Thread(new PlayerClientSignInThread(playerClientEU, "Clinton", "bcbc1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Bush", "gbgb1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Xi", "jxjx1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Merkel", "amam1234", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignInThread(playerClientEU, "Hollande", "fhfh1234", clientIPAddressEU)).start();
			
			
			new Thread(new PlayerClientSignInThread(playerClientNA, "Clinton", "bcbc1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Bush", "gbgb1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Xi", "jxjx1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Merkel", "amam1234", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignInThread(playerClientNA, "Hollande", "fhfh1234", clientIPAddressNA)).start();
			
			
			new Thread(new PlayerClientSignInThread(playerClientAS, "Clinton", "bcbc1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Bush", "gbgb1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Xi", "jxjx1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Merkel", "amam1234", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignInThread(playerClientAS, "Hollande", "fhfh1234", clientIPAddressAS)).start();
			
			*/
			new Thread(new PlayerClientSignOutThread(playerClientEU, "Clinton", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignOutThread(playerClientEU, "Bush", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignOutThread(playerClientEU,"Xi", clientIPAddressEU)).start();
			new Thread(new PlayerClientSignOutThread(playerClientEU, "Merkel", clientIPAddressEU)).start();
			
			new Thread(new PlayerClientSignOutThread(playerClientNA, "Clinton", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignOutThread(playerClientNA, "Bush", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignOutThread(playerClientNA,"Xi", clientIPAddressNA)).start();
			new Thread(new PlayerClientSignOutThread(playerClientNA, "Merkel", clientIPAddressNA)).start();
			
			
			new Thread(new PlayerClientSignOutThread(playerClientAS, "Clinton", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignOutThread(playerClientAS, "Bush", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignOutThread(playerClientAS,"Xi", clientIPAddressAS)).start();
			new Thread(new PlayerClientSignOutThread(playerClientAS, "Merkel", clientIPAddressAS)).start();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
